package com.googlecode.garbagecan.clickstudy.page;

import com.googlecode.garbagecan.clickstudy.BorderTemplate;
import org.apache.click.ActionListener;
import org.apache.click.Control;
import org.apache.click.control.ActionLink;
import org.apache.click.util.Bindable;

import java.util.Calendar;

public class ListenerPage extends BorderTemplate {
	@Bindable
	protected String title = "Home";

	@Bindable
	protected ActionLink myLink1 = new ActionLink(this, "onLink1Click");

	@Bindable
	protected ActionLink myLink2 = new ActionLink();

	@Bindable
	protected String msg;

	public ListenerPage() {
		addModel("time", Calendar.getInstance().getTime());
		myLink2.setActionListener(new ActionListener() {
			public boolean onAction(Control control) {
				msg = "ListenerPage#" + hashCode() + " object method <tt>onAction()</tt> invoked.";
				return true;
			}
		});
	}

	public boolean onLink1Click() {
		msg = "ListenerPage#" + hashCode() + " object method <tt>onLink1Click()</tt> invoked.";
		return true;
	}
}
